package cn.felord.websocket.controller;

import cn.felord.websocket.bean.User;
import cn.felord.websocket.config.WebSocketHandlerProxy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Dax
 * @since 16:39  2018/7/6
 */
@RestController
@RequestMapping("/socket")
public class SocketController {
    @Resource
    private WebSocketHandlerProxy webSocketHandler;

    @GetMapping("/send")
    public void send() throws Exception {
        User user = new User();
        user.setName("websocket");
        user.setAge(22);
        user.setAlive(false);
        webSocketHandler.handleJsonMessage(user);
    }

}
